﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Smith.ImageConverter
{
    public interface IGenerateor
    {
        string GetNext();
    }

    public class SerialGenerator : IGenerateor
    {
        public SerialGenerator(string prefix, string suffix, int seed, int digit)
        {
            Prefix = prefix;
            Suffix = suffix;
            Seed = seed;
            Digit = digit;
            Reset();
        }

        /// <summary>
        /// reset the generator
        /// </summary>
        public void Reset()
        {
            Current = Seed - 1;
        }

        /// <summary>
        /// generate next serial name
        /// </summary>
        public string GetNext()
        {
            Current++;
            return string.Format("{0}{1}{2}",
                Prefix, Current.ToString("D" + Digit), Suffix);
        }

        public string Prefix { get; private set; }
        public string Suffix { get; private set; }
        public int Seed { get; private set; }
        public int Digit { get; private set; }
        private int Current { get; set; }
    }

    public class TimeSerialGenerator : IGenerateor
    {
        public string GetNext()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmssffff");
        }
    }
}
